package com.xyy.saas.payment.util;

import io.micrometer.core.instrument.MeterRegistry;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class SkyWalkingMonitorUtil {
    /**
     * 支付回调耗时，渠道到支付平台
     */
    public static final String CALLBACK_CHANNEL_COST_PREFIX = "callback_channel_cost_";

    /**
     * 支付回调耗时，支付平台保存订单
     */
    public static final String CALLBACK_PAYMENT_SAVE_COST = "callback_payment_save_cost";

    /**
     * 支付回调耗时，支付平台回调业务
     */
    public static final String CALLBACK_NOTIFY_BUSINESS_COST_PREFIX = "callback_notify_business_cost_";

//    @Autowired
//    private MeterRegistry meterRegistry;

    /**
     * 汇总统计
     * @param lineName
     * @param value
     */
    public void summary(String lineName, double value) {
        try {
//            meterRegistry.summary(lineName).record(value);
        }
        catch(Exception ex) {
            log.error(ex.getMessage(), ex);
        }
    }
}
